import { clientFetch } from '@/utils/request';

export interface RenderRequest {
  /**
   * Optional - Convert the document into another format. Accepted values: ods xlsx xls csv
   * pdf txt odp ppt pptx jpg png odt doc docx txt jpg png epub html xml idml. List of
   * supported formats: https://carbone.io/documentation.html#supported-files-and-features-list
   */
  convertTo?: string;
  /**
   * Required - ️JSON data-set merged into the template to generate a document
   */
  data?: { [key: string]: any };
  [property: string]: any;
}

export const sendReportRender = async ({ convertTo, data }: RenderRequest) => {
  const res = await clientFetch.post(
    `http://localhost:8000/render`,
    {
      template_id: '32',
      data,
    },
    {
      responseType: 'blob' as "json",
    }
  );

  return res;
};
